<template>
  <div
    class="app-container"
    style="height: 100%"
    v-loading="loadingSave"
    element-loading-text="加载中..."
  >
    <el-container>
      <el-header style="position: sticky; width: 100%">
        <div class="footer_btn_save_top">
          <h3>{{ route.params.id ? '编辑服务商' : '新增服务商' }}</h3>
          <div class="footer_btn_save">
            <HPlainButton @click="addSave(formRef)">保存</HPlainButton>
            <HButton @click="onBack"> 取消 </HButton>
          </div>
        </div>
      </el-header>
      <el-container style="margin-top: 4px">
        <el-main>
          <div class="app-container-inner">
            <!-- 创建网点 -->
            <div class="create-work">
              <el-form
                label-position="right"
                ref="formRef"
                :model="data"
                require-asterisk-position="left"
                :rules="rules"
                label-width="85"
              >
                <h3 class="title" style="margin-bottom: 12px">基本信息</h3>
                <section class="basic_information">
                  <ul class="left_info">
                    <li>
                      <!--服务商名称-->
                      <el-form-item label="服务商名称" prop="name">
                        <el-input
                          style="width: 250px"
                          placeholder="请输入服务商名称"
                          v-model="data.name"
                          clearable
                        />
                      </el-form-item>

                      <!--服务商编号-->
                      <el-form-item label="服务商编号">
                        <el-input
                          v-model="data.code"
                          placeholder="如不填写，则系统自动生成"
                          clearable
                          style="width: 250px"
                        />
                      </el-form-item>

                      <!--服务商分类-->
                      <el-form-item label="服务商分类" prop="networkTypeId">
                        <el-select
                          placeholder="请选择"
                          filterable
                          clearable
                          v-model="data.networkTypeId"
                          :filter-method="handleGetNetworkTypeOptions"
                          :loading="getNetworkTypeOptionsLoading"
                          remote-show-suffix
                          style="width: 250px"
                        >
                          <el-option
                            v-for="item in networkTypeOptions"
                            :key="item.name"
                            :value="item.id"
                            :label="item.name"
                          />
                        </el-select>
                      </el-form-item>

                      <!--团队模式-->
                      <el-form-item label="团队模式">
                        <el-select
                          style="width: 250px"
                          v-model="data.teamType"
                          placeholder="请选择"
                          clearable
                        >
                          <el-option
                            v-for="item in typeList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                          />
                        </el-select>
                      </el-form-item>

                      <!--服务商地址-->
                      <el-form-item required label="服务商地址" prop="province">
                        <SingleAddress
                          ref="addrsDom"
                          :address="addrs"
                          class="addrsDom_"
                          style="width: 250px"
                          @value-change="addressValChange"
                        />
                      </el-form-item>

                      <!--详细地址-->
                      <el-form-item label="详细地址" prop="address">
                        <el-input
                          v-model="data.address"
                          :autosize="{ minRows: 1, maxRows: 4 }"
                          type="textarea"
                          maxlength="200"
                          show-word-limit
                          placeholder="请输入详细地址"
                          clearable
                          style="width: 250px"
                        />
                      </el-form-item>
                    </li>
                    <li>
                      <!--服务商模式-->
                      <el-form-item label="服务商模式" prop="category">
                        <el-select
                          style="width: 250px"
                          v-model="data.category"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in categoryList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                          />
                        </el-select>
                      </el-form-item>

                      <!--工单策略-->
                      <el-form-item label="工单策略">
                        <HButton type="primary" @click="oredrDialog = true">
                          前往编辑策略
                          <el-icon class="icon_right" color="#007cff" size="14">
                            <Right />
                          </el-icon>
                        </HButton>
                      </el-form-item>

                      <!--服务商状态-->
                      <el-form-item label="服务商状态">
                        <el-radio-group v-model="data.status">
                          <el-radio :value="false">启用</el-radio>
                          <el-radio :value="true">禁用</el-radio>
                        </el-radio-group>
                      </el-form-item>

                      <!--服务商范围-->
                      <el-form-item label="服务范围">
                        <MultipleAddress
                          ref="addrsDom_ser"
                          :address="addrs2"
                          class="addrsDom_"
                          style="height: 28px; width: 300px"
                          @value-change="addressValChange2"
                          :max-collapse-tags="2"
                        />
                      </el-form-item>
                    </li>
                  </ul>
                </section>
                <h3 class="title" style="margin-bottom: 12px">账号信息</h3>
                <div style="display: flex; flex-wrap: wrap">
                  <!--绑定账号-->
                  <el-form-item label="绑定账号" prop="phone" class="basic_information">
                    <div style="display: flex; align-items: center; gap: 12px">
                      <el-input
                        v-model="data.phone"
                        maxlength="11"
                        clearable
                        placeholder="请输入绑定的手机号"
                        @keyup="handleInputPhone"
                        style="height: 28px; width: 250px"
                      />
                      <HPlainButton
                        @click="empPageSelecctList(data.phone)"
                        :loading="queryInfoAccountLoading"
                        >查询
                      </HPlainButton>
                    </div>
                  </el-form-item>

                  <!--负责人员-->
                  <el-form-item class="basic_information" label="账号名称" prop="accountName">
                    <span class="flex_item">
                      <el-input
                        :disabled="isInput"
                        v-model="data.accountName"
                        clearable
                        placeholder="账号名字"
                        style="width: 250px"
                      />
                      <el-tooltip effect="light" content="获取不到则手动输入！" placement="right">
                        <el-icon size="18" class="ma_left" color="#ff5733">
                          <Warning />
                        </el-icon>
                      </el-tooltip>
                    </span>
                  </el-form-item>
                </div>
                <div style="display: flex; align-items: center; gap: 5px; margin-bottom: 12px">
                  <h3 class="title">服务商结算</h3>
                  <HPlainButton @click="onAddItem" :height="22" :padding-lr="6">新增</HPlainButton>
                </div>
                <section class="table_list">
                  <el-table :data="data.moduleSettlements" :border="true" stripe resizable>
                    <template #empty>
                      <el-empty description="暂无数据" :image-size="140" />
                    </template>
                    <!--序号-->
                    <el-table-column label="序号" width="70" fixed>
                      <template v-slot="scope">
                        <span class="order"> {{ scope.$index + 1 }} </span>
                        <span class="add_delete">
                          <el-icon size="16" color="#007cff" class="add" @click="onAddItem()">
                            <CirclePlus />
                          </el-icon>
                          <el-icon
                            color="rgba(245, 108, 108, 1)"
                            size="16"
                            @click="detelePri(scope.row, scope.$index)"
                          >
                            <Delete />
                          </el-icon>
                        </span>
                      </template>
                    </el-table-column>

                    <!-- 模块名称 -->
                    <el-table-column
                      show-overflow-tooltip
                      label="模块名称"
                      prop="name"
                      min-width="200"
                    >
                      <template v-slot="i">
                        <el-select
                          placeholder="请选择模块"
                          filterable
                          clearable
                          v-model="i.row.moduleId"
                          :filter-method="(val: string) => inputWorkModChange(val, i.$index)"
                          :loading="loading"
                          remote-show-suffix
                        >
                          <el-option
                            v-for="item in i.row.workModulePrice"
                            :key="item.name"
                            :disabled="isStop(item.id)"
                            :value="item.id"
                            :label="item.name"
                          />
                        </el-select>
                      </template>
                    </el-table-column>

                    <!--模块默认费用-->
                    <el-table-column show-overflow-tooltip label="模块默认费用" min-width="120">
                      <template v-slot="item">
                        <el-input
                          :value="
                            item.row.moduleId
                              ? item.row.workModulePrice?.filter(
                                  (o) => item.row.moduleId == o.id,
                                )[0]?.price
                              : ''
                          "
                          disabled
                        >
                          <template #prepend>￥</template>
                        </el-input>
                      </template>
                    </el-table-column>

                    <!--服务商结算费用-->
                    <el-table-column
                      prop="qty"
                      show-overflow-tooltip
                      label="服务商结算费用"
                      min-width="140"
                    >
                      <template #header>
                        服务商结算费用
                        <el-popover
                          placement="top-start"
                          ref="popover3"
                          trigger="click"
                          :width="160"
                        >
                          <h5 style="margin-bottom: 10px">批量填充</h5>
                          <el-input
                            placeholder="请输入"
                            v-model="Allprice"
                            @input="Allprice = Allprice.replace(/[^0-9]/g, '')"
                            @keyup.enter="changeAllAllprice"
                          />

                          <div style="display: flex; justify-content: end; margin-top: 10px">
                            <el-button
                              color="#007cff"
                              style="padding: 0 4px; height: 20px"
                              @click="changeAllAllprice"
                              >确定</el-button
                            >
                          </div>
                          <template #reference>
                            <span class="multiple_btn">批量</span>
                          </template>
                        </el-popover>
                      </template>
                      <template v-slot="item">
                        <el-input
                          v-model="item.row.price"
                          placeholder="结算价"
                          @input="item.row.price = item.row.price.replace(/[^0-9]/g, '')"
                          style="height: 28px"
                        >
                          <template #prepend>￥</template>
                        </el-input>
                      </template>
                    </el-table-column>
                  </el-table>
                </section>
              </el-form>
            </div>
          </div>
        </el-main>

        <!--其他信息-->
        <el-aside v-if="data.fieldVals.length > 0" width="24vw" style="margin-left: 12px">
          <div class="app-container-inner">
            <el-form
              label-position="right"
              ref="formRef2"
              :model="data"
              require-asterisk-position="left"
              :rules="rules"
              label-width="auto"
            >
              <h3 class="title" style="margin-bottom: 12px">其他信息</h3>
              <section class="basic_information">
                <div class="defined_sty">
                  <template v-for="(item, bigindex) in data.fieldVals" :key="item.id">
                    <el-form-item
                      :label="item.name"
                      :required="item.required"
                      :prop="`fieldVals[${bigindex}][${
                        item.type === 5 || item.type === 6 || item.type === 7 ? 'imgarr' : 'value'
                      }]`"
                      :rules="[
                        { required: item.required, message: item.tip, trigger: ['blur', 'change'] },
                      ]"
                    >
                      <!-- 文本1 -->
                      <el-input
                        v-if="item.type === 1"
                        :placeholder="item.tip"
                        style="width: 220px"
                        type="text"
                        v-model="item.value"
                        clearable
                      />

                      <!-- 多行文本2 -->
                      <el-input
                        v-if="item.type === 2"
                        style="width: 220px"
                        :rows="1"
                        v-model="item.value"
                        type="textarea"
                        maxlength="200"
                        :placeholder="item.tip"
                        show-word-limit
                      />

                      <!-- 单选3 -->
                      <el-select
                        v-model="item.value"
                        style="width: 220px"
                        v-if="item.type === 3 && item.contents.length > 3"
                        :placeholder="item.tip"
                        clearable
                      >
                        <el-option
                          v-for="i in item.contents"
                          :key="i.id"
                          :label="i.val"
                          :value="i.val"
                        />
                      </el-select>
                      <el-radio-group
                        v-else-if="item.type === 3"
                        class="input_w"
                        v-model="item.value"
                      >
                        <el-radio v-for="i in item.contents" :key="i.id" :value="i.val">{{
                          i.val
                        }}</el-radio>
                      </el-radio-group>

                      <!-- 多选4 -->
                      <el-select
                        v-model="item.value"
                        style="width: 220px"
                        v-if="item.type === 4 && item.contents.length > 3"
                        :placeholder="item.tip"
                        clearable
                        multiple
                        collapse-tags
                        collapse-tags-tooltip
                      >
                        <el-option
                          v-for="i in item.contents"
                          :key="i.id"
                          :label="i.val"
                          :value="i.val"
                        />
                      </el-select>
                      <el-checkbox-group
                        v-else-if="item.type === 4"
                        class="input_w"
                        v-model="item.value"
                      >
                        <el-checkbox v-for="i in item.contents" :key="i.id" :value="i.val">{{
                          i.val
                        }}</el-checkbox>
                      </el-checkbox-group>

                      <!-- 图片567 -->
                      <div
                        class="upload_file"
                        v-if="item.type === 5 || item.type === 6 || item.type === 7"
                      >
                        <el-upload
                          :auto-upload="false"
                          v-model="item.imgarr"
                          style="width: 220px"
                          :accept="item.type == 5 ? 'image/*' : item.type == 6 ? '.pdf' : 'video/*'"
                          drag
                          action="#"
                          multiple
                          :show-file-list="false"
                          :on-change="
                            (file) => {
                              handleChange2(file, item)
                            }
                          "
                        >
                          <el-icon class="up_icon">
                            <UploadFilled />
                          </el-icon>
                          <div
                            >点击上传{{
                              item.type == 5 ? '图片' : item.type == 6 ? 'pdf格式文件' : '视频'
                            }}</div
                          >
                        </el-upload>
                        <ul class="ul_list">
                          <li class="li_item" v-for="(it, index) in item.imgarr" :key="index">
                            <div class="li_item_left">
                              <img
                                :src="pdf"
                                alt=""
                                style="width: 30px; height: 30px; cursor: pointer"
                                @click.stop="lookFile(it.image, 'pdf')"
                                v-if="
                                  it.name
                                    ? it.name.replace(/.+\./, '') == 'pdf'
                                    : it.image.replace(/.+\./, '') == 'pdf'
                                "
                              />
                              <el-icon
                                style="cursor: pointer"
                                v-else-if="
                                  right_type.includes(
                                    it.name
                                      ? it.name.replace(/.+\./, '')
                                      : it.image.replace(/.+\./, ''),
                                  )
                                "
                                size="30"
                                @click.stop="lookFile(it.image, 'film')"
                              >
                                <Film />
                              </el-icon>
                              <el-image
                                v-else
                                :preview-src-list="[it.image]"
                                style="width: 30px; height: 30px"
                                :src="it.image"
                                fit="contain"
                              />
                              <el-tooltip effect="dark" placement="top">
                                <template #content>
                                  {{
                                    it.name
                                      ? it.name
                                      : it.image?.substring(
                                          it.image.lastIndexOf('/') + 1,
                                          it.image.lastIndexOf('_'),
                                        ) + it.image?.substring(it.image.lastIndexOf('.'))
                                  }}
                                </template>
                                <span class="pic_name">{{
                                  it.name
                                    ? it.name
                                    : it.image?.substring(
                                        it.image.lastIndexOf('/') + 1,
                                        it.image.lastIndexOf('_'),
                                      ) + it.image?.substring(it.image.lastIndexOf('.'))
                                }}</span>
                              </el-tooltip>
                            </div>
                            <el-icon
                              size="16"
                              class="del_btn"
                              @click.stop="deleteItem2(bigindex, index)"
                            >
                              <Delete />
                            </el-icon>
                          </li>
                        </ul>
                      </div>
                    </el-form-item>
                  </template>
                </div>
              </section>
            </el-form>
          </div>
        </el-aside>
      </el-container>
    </el-container>

    <!-- 修改工单策略弹窗 -->
    <HModal v-model="oredrDialog" title="工单策略" :width="500">
      <el-form
        :model="data.strategy"
        label-width="96"
        label-position="right"
        class="modal_form_content"
      >
        <!--接单策略-->
        <el-form-item label="接单策略" class="form_radio_group_item">
          <el-radio-group
            :disabled="data.teamType === 2"
            v-model="data.strategy.autoSureReceiveOrder"
          >
            <el-radio :value="true">自动接单</el-radio>
            <el-radio :value="false">手动接单</el-radio>
          </el-radio-group>
        </el-form-item>

        <!--取消工单-->
        <el-form-item label="取消工单" class="form_radio_group_item">
          <el-radio-group v-model="data.strategy.autoCheckCancelOrder">
            <el-radio :value="false">人工审核</el-radio>
            <el-radio :value="true">自动审核</el-radio>
          </el-radio-group>
        </el-form-item>

        <!--结单审核-->
        <el-form-item label="结单审核" class="form_radio_group_item">
          <el-radio-group v-model="data.strategy.autoCheckEndOrder">
            <el-radio :value="false">人工审核</el-radio>
            <el-radio :value="true">自动审核</el-radio>
          </el-radio-group>
        </el-form-item>

        <!--配件价格-->
        <el-form-item label="配件价格" class="form_radio_group_item">
          <el-radio-group v-model="data.strategy.enableUpdateSparePrice">
            <el-radio :value="true">允许修改</el-radio>
            <el-radio :value="false">不允许修改</el-radio>
          </el-radio-group>
        </el-form-item>

        <!-- 工单费用查看 -->
        <el-form-item label="工单费用查看" class="form_radio_group_item">
          <el-radio-group v-model="data.strategy.allowSelectFee">
            <el-radio :value="true">允许查看</el-radio>
            <el-radio :value="false">不允许查看</el-radio>
          </el-radio-group>
        </el-form-item>

        <!-- 费用查看权限 -->
        <el-form-item label="费用查看权限" class="form_input_item">
          <el-select
            v-model="data.strategy.selectFeeEmpRootVos"
            collapse-tags
            :disabled="!data.strategy.allowSelectFee"
            collapse-tags-tooltip
            placeholder="选择费用查看权限"
            filterable
            multiple
            :filter-method="getNetworkEmpPageSelectList"
            :loading="getNetworkEmpOptionalLoading"
            remote-show-suffix
            clearable
            @change="updateWithdrawalRules"
          >
            <el-option label="团队负责人" value="-1" />
            <el-option
              v-for="item in networkEmpOptional"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>

        <!-- 提现权限 -->
        <el-form-item label="提现权限" class="form_radio_group_item">
          <el-radio-group v-model="data.strategy.allowWithdrawal">
            <el-radio :value="true">允许提现</el-radio>
            <el-radio :value="false">不允许提现</el-radio>
          </el-radio-group>
        </el-form-item>

        <!-- 提现人员 -->
        <el-form-item label="提现人员" class="form_input_item">
          <el-select
            v-model="data.strategy.withdrawEmpRootVos"
            collapse-tags
            collapse-tags-tooltip
            placeholder="提现人员"
            filterable
            multiple
            :disabled="!data.strategy.allowWithdrawal"
            :filter-method="getNetworkEmpPageSelectList"
            :loading="getNetworkEmpOptionalLoading"
            remote-show-suffix
            clearable
            @change="updateWithdrawalRules"
          >
            <el-option label="团队负责人" value="-1" />
            <el-option
              v-for="item in networkEmpOptional"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>

        <!-- 提现规则 -->
        <el-form-item label="提现规则" class="form_input_item">
          <el-checkbox v-model="data.strategy.allowManagerHelpWithdraw">
            是否允许管理员代提现
          </el-checkbox>
        </el-form-item>

        <!--提现手续费-->
        <el-form-item label="提现手续费策略" class="form_radio_group_item">
          <el-radio-group v-model="data.strategy.withdrawHandlingFeeStrategy">
            <el-radio :value="1">按比例收取</el-radio>
            <el-radio :value="2">每年固定</el-radio>
          </el-radio-group>
        </el-form-item>

        <!--手续费比例-->
        <el-form-item label="手续费比例(%)" class="form_input_item">
          <el-input
            v-model="data.strategy.handingFeeProportion"
            :disabled="data.strategy.withdrawHandlingFeeStrategy == 2"
            placeholder=""
            @input="
              data.strategy.handingFeeProportion = autoFixedDicimal(
                data.strategy.handingFeeProportion,
              )
            "
            @change="
              data.strategy.handingFeeFixedOrder = Number(data.strategy.handingFeeProportion)
            "
          />
        </el-form-item>

        <!--每单固定手续费-->
        <el-form-item label="每单固定手续费" class="form_input_item">
          <el-input
            v-model="data.strategy.handingFeeFixedOrder"
            :disabled="data.strategy.withdrawHandlingFeeStrategy == 1"
            placeholder=""
            @input="
              data.strategy.handingFeeFixedOrder = autoFixedDicimal(
                data.strategy.handingFeeFixedOrder,
              )
            "
            @change="
              data.strategy.handingFeeFixedOrder = Number(data.strategy.handingFeeFixedOrder)
            "
          >
            <template #prepend> ￥ </template>
          </el-input>
        </el-form-item>
      </el-form>

      <template #footerRight>
        <HButton is-modal @click="oredrDialog = false" type="primary">确定</HButton>
        <HButton is-modal @click="oredrDialog = false">取消</HButton>
      </template>
    </HModal>

    <!-- 修改质保标准弹窗 -->
    <el-dialog
      v-model="quaDialog"
      title="修改网点质保标准"
      width="500px"
      :draggable="true"
      :destroy-on-close="true"
      :close-on-click-modal="false"
      class="qua-dialog"
      top="8vh"
    >
      <div class="cards">
        <div class="card">
          <label>服务类型</label>
          <el-input v-model="input11" disabled class="input-w" />
        </div>
        <div class="card">
          <label>默认时间</label>
          <el-input v-model="input12" disabled class="input-w" />
        </div>
        <div class="card">
          <label>网点时间</label>
          <el-input v-model="input13" class="input-w" />
        </div>
        <p>质保时间修改后，只针对新工单有效，已完成工单和进展中工单不受影响</p>
      </div>
      <div class="btns">
        <HButton type="primary">保存</HButton>
        <HButton @click="quaDialog = false"> 取消 </HButton>
      </div>
    </el-dialog>

    <!-- 修改费用标准弹窗 -->
    <el-dialog
      v-model="costDialog"
      title="修改网点费用标准"
      width="500px"
      :draggable="true"
      :destroy-on-close="true"
      :close-on-click-modal="false"
      class="qua-dialog"
      top="8vh"
    >
      <div class="cards">
        <div class="card">
          <label>费用类型</label>
          <el-input v-model="input14" disabled class="input-w" />
        </div>
        <div class="card">
          <label>默认费用</label>
          <el-input v-model="input15" disabled class="input-w" />
        </div>
        <div class="card">
          <label>网点费用</label>
          <el-input v-model="input16" class="input-w" />
        </div>
        <p>费用标准修改后，只针对未审核费用有效，已审核和已结算费用不受影响</p>
      </div>
      <div class="btns">
        <el-button @click="costDialog = false" class="btn_cancel"> 取消 </el-button>
        <el-button color="#007cff" class="btn_save">保存</el-button>
      </div>
    </el-dialog>

    <!-- 文件查看 -->
    <el-dialog
      :title="isPdf == 'pdf' ? '查看附件' : '查看视频'"
      v-model="dialogContract"
      :draggable="true"
      :destroy-on-close="true"
      :close-on-click-modal="false"
    >
      <iframe
        :src="`${file}`"
        v-if="isPdf == 'pdf'"
        width="100%"
        height="700"
        frameborder="0"
      ></iframe>
      <video :src="`${file}`" v-else style="width: 100%" controls autoplay></video>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref, watch } from 'vue'
  import useNetwork from './useNetwork'
  import { Delete, Film, UploadFilled, CirclePlus, Warning, Right } from '@element-plus/icons-vue'
  import SingleAddress from '@/components/address/singleAddress.vue'
  import MultipleAddress from '@/components/address/multipleAddress.vue'
  import pdf from '@/assets/image/pdf.png'
  import { useGetNetworkTypeOptionsService } from './services/index'
  import _ from 'lodash'
  import { useRoute } from 'vue-router'
  import autoFixedDicimal from '@/utils/money'
  import pageComponentName from '@/config/page-component-name'

  defineOptions({
    name: pageComponentName.network.networkForm,
  })

  const route = useRoute()

  // 使用获取服务商分类下拉选项服务
  const {
    options: networkTypeOptions,
    getOptions: getNetworkTypeOptions,
    loading: getNetworkTypeOptionsLoading,
  } = useGetNetworkTypeOptionsService

  let {
    networkTypePageSelectList,
    getBeforeNetworkEditSelectData,
    getnetworkFieldSelect,
    data,
    dialogContract,
    file,
    isPdf,
    categoryList,
    formRef2,
    addrs,
    addrs2,
    isInput,
    formRef,
    loadingSave,
    detelePri,
    Allprice,
    changeAllAllprice,
    handleChange2,
    typeList,
    lookFile,
    deleteItem2,
    onBack,
    addSave,
    addressValChange,
    addressValChange2,
    loading,
    onAddItem,
    inputWorkModChange,
    addrsDom_ser,
    addrsDom,
    oredrDialog,
    rules,
    empPageSelecctList,
    queryInfoAccountLoading,
    networkEmpOptional,
    getNetworkEmpPageSelectList,
    getNetworkEmpOptionalLoading,
  } = useNetwork()
  var right_type = [
    'avi',
    'wmv',
    'mpg',
    'mpeg',
    'mov',
    'rm',
    'ram',
    'swf',
    'flv',
    'mp4',
    'wma',
    'rm',
    'rmvb',
    'flv',
    'mpg',
    'mkv',
  ]
  // 修改质保标准
  const input11 = ref('安装') // 服务类型
  const input12 = ref(60) // 默认时间
  const input13 = ref('') // 网点时间
  // 修改费用标准
  const input14 = ref('测试') // 费用类型
  const input15 = ref(666) // 默认费用
  const input16 = ref('') // 网点费用
  const quaDialog = ref(false)
  const costDialog = ref(false)

  const isStop = (id: string) => {
    return data.value.moduleSettlements
      .map((o) => {
        return o.moduleId
      })
      .includes(id)
  }

  // 手机号输入事件
  const handleInputPhone = (event: Event) => {
    ;(event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.replace(
      /[^\d]/g,
      '',
    )
  }

  /**
   * 获取服务商分类
   */
  const handleGetNetworkTypeOptions = _.throttle((query: string) => {
    getNetworkTypeOptions(query)
  }, 500)

  const getData = async () => {
    await networkTypePageSelectList('')
    await getNetworkTypeOptions('')
    if (route.params.id) {
      await getBeforeNetworkEditSelectData(route.params.id as string)
    } else {
      await onAddItem()
      await getnetworkFieldSelect()
      handleGetNetworkTypeOptions('')
    }
  }

  /**
   * 修改提现规则
   */
  const updateWithdrawalRules = () => {
    const { selectFeeEmpRootVos, withdrawEmpRootVos } = data.value.strategy
    if (selectFeeEmpRootVos.includes('-1') && withdrawEmpRootVos.includes('-1')) {
      data.value.strategy.allowManagerHelpWithdraw = true
    } else {
      data.value.strategy.allowManagerHelpWithdraw = false
    }
  }

  // 监听团队模式
  watch(
    () => data.value.teamType,
    (n) => {
      if (n == 2) {
        data.value.strategy.autoSureReceiveOrder = true
      }
    },
  )

  onMounted(() => {
    getData()
  })
</script>

<style scoped lang="scss">
  @import './index';
</style>
